// 订单相关操作的api

import service from "./index";
const prifex = "/indent";

// 根据id修改订单数据
export function updateById(updateForm) {
  return service({
    url: `${prifex}/updateById`,
    method: "PUT",
    data: updateForm,
  });
}

// 新增订单请求
export function addIndent(addForm) {
  return service({
    url: `${prifex}/addIndent`,
    method: "POST",
    data: addForm,
  });
}

// 页面查询
export function pageList(pageInfo, searchForm) {
  const params = {};
  if (pageInfo) {
    params.pageNum = pageInfo.pageNum;
    params.pageSize = pageInfo.pageSize;
  }

  if (searchForm) {
    params.indentId = searchForm.indentId;
    params.userName = searchForm.userName;
    params.goodsName = searchForm.goodsName;
    params.addressName = searchForm.addressName;
    params.status = searchForm.status;
  }

  return service({
    url: `${prifex}/pageList`,
    method: "GET",
    params: params,
  });
}

// 根据订单id查询订单信息
export function getById(id) {
  return service({
    url: `${prifex}/getById/${id}`,
    method: "GET",
  });
}

// 根据订单id删除订单数据
export function deleteById(id) {
  return service({
    url: `${prifex}/deleteById/${id}`,
    method: "DELETE",
  });
}

// 发货
export function shipments(id) {
  return service({
    url: `${prifex}/shipments/${id}`,
    method: "PUT",
  });
}

// 收货
export function receipt(id) {
  return service({
    url: `${prifex}/receipt/${id}`,
    method: "PUT",
  });
}

// 支付
export function payIndent(id) {
  return service({
    url: `${prifex}/payIndent/${id}`,
    method: "POST",
  });
}
